import 'package:dss_base/dss_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 对话框改变状态
enum LoadingDialogState { init, show, hide }

/// 全局的 loading 对话框
Widget loadingDialog = Center(
  child: Container(
    width: 100.w,
    height: 100.w,
    decoration: const BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.all(Radius.circular(10)),
    ),
    padding: EdgeInsets.all(20.w),
    child: const CircularProgressIndicator(),
  ),
);

/// 页面状态
enum PageState {
  initState,
  loadingState,
  successState,
  failureState,
  emptyState,
}

/// 页面状态视图
class PageStateHolder {
  PageStateHolder._();

  static final PageStateHolder _singleton = PageStateHolder._();

  factory PageStateHolder() => _singleton;

  static PageStateHolder get instance => _singleton;

  Widget initStatePage = const Center(child: CircularProgressIndicator());

  Widget loadingStatePage = const Center(child: CircularProgressIndicator());

  Widget createFailureStatePage() => Column(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
      ImageX(urlOrPath: 'ic_1.png'),
      Gaps.vGap10,
      Text(
        'Error',
        style: TextStyle(fontSize: 18.sp, color: ColorsX.color_181818),
      ),
    ],
  );

  Widget createEmptyStatePage() => Column(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
      ImageX(urlOrPath: 'ic_1.png'),
      Gaps.vGap10,
      Text(
        'No data',
        style: TextStyle(fontSize: 18.sp, color: ColorsX.color_181818),
      ),
    ],
  );
}
